QuickTime 4 API Documentation

3D Graphics Programming with QuickDraw 3D 1.5.4

Previous | QD3D Book | Overview | Chapter Contents | Next |

Texture Operations

A drawing engine may support a texture mapping operation that determines how a drawing engine performs texture mapping. You specify an engine's texture mapping operation by assigning a value to its kQATag_TextureOp state variable. The default value of this variable for a drawing engine that supports texture mapping is kQATextureOp_None .

You can use the following masks to specify a texture mapping operation. The bits are ORed together to determine the desired operation.

#define kQATextureOp_None                           0
#define kQATextureOp_Modulate                       (1 << 0)
#define kQATextureOp_Highlight                      (1 << 1)
#define kQATextureOp_Decal                          (1 << 2)
#define kQATextureOp_Shrink                         (1 << 3)

Constant descriptions

kQATextureOp_None
The drawing engine supports no special texture mapping operations. The drawing engine simply replaces an object's color with the texture map color. This mode results in a flat-looking image with no lighting effects, which is most useful when the texture mapping engine is used as a 2D warping engine (for example, for video effects). The texture map's alpha channel values control the transparency of a rendered object on a per-pixel basis. The alpha channel value of a particular pixel is the product of texture map's alpha channel value and the vertex alpha channel value (which is interpolated from the TQAVTexture data structure).
kQATextureOp_Modulate
The texture map color is modulated with the interpolated diffuse colors (from the kd_r , kd_g , and kd_b fields of a texture vertex).
kQATextureOp_Highlight
The interpolated specular colors (from the ks_r , ks_g , and ks_b fields of a texture vertex) are added to the texture map color.
kQATextureOp_Decal
The texture map alpha channel value is used to blend the texture map color and the interpolated decal colors (from the r , g , and b fields of a texture vertex). When the texture map alpha channel value is 0, the texture map color is replaced with the interpolated r , g , and b values.
kQATextureOp_Shrink
The drawing engine modifies any u and v values so that they always lie in the range 0.0 to 1.0 inclusive. This guarantees that wrapping not occur. In theory, u and v values in the range [0.0, 1.0] should never cause wrapping. In practice, however, errors that occur during uv interpolation can cause uv overflow or underflow, which can result in occasional one pixel texture wrapping at the 0.0 and 1.0 boundaries.

The clamping specified by the kQATextureOp_Shrink flag is not the same type of OpenGL texture clamping specified by the kQATagGL_TextureWrapU and kQATagGL_TextureWrapV state variables (see "Texture Wrapping Values" ). OpenGL clamping is designed to accept arbitrary uv values, while clamping specified by the kQATextureOp_Shrink flag operates only on uv values in the range 0.0 to 1.0. The kQATextureOp_Shrink clamping is therefore less expensive to implement (perhaps simply by compressing the range of u and v slightly before beginning interpolation). Any drawing engine that does support OpenGL clamping can use that code to support kQATextureOp_Shrink clamping.


© 1997 Apple Computer, Inc.

Previous | QD3D Book | Overview | Chapter Contents | Next |